<?php
if (!defined("IN_OP"))
{
    exit("You can't access this file directly...");
}
include_once( "class/function_3d.php" );
$bettype = intval(getvar("bettype"));
$subid = intval(getvar("subid"));
$lotto_id = intval(getvar("lotto_id"));
$chk = 0;
if ($bettype == 27 && ( 2 <= $subid && $subid <= 5 ))
{
    $chk = 1;
}
else if ($bettype == 36 && ( 21 <= $subid && $subid <= 51 ))
{
    $chk = 1;
}
else
{
    exit("error bettype");
}
$ui = new UI();
$tpl = new Template2();
$rs = getdb("select * from rate{$bettype} where lotto_id={$lotto_id} and disk=1 and subid={$subid}");
if ($rs->eof)
{
    getdb("insert into rate{$bettype} (lotto_id,disk,subid) values ({$lotto_id},1,{$subid}),({$lotto_id},2,{$subid}),({$lotto_id},3,{$subid});");
    $rs = getdb("select * from rate{$bettype} where lotto_id={$lotto_id} and disk=1 and subid={$subid}");
}
$html = "<table width='100%' border='1' cellpadding='5' class='table'><tr>";
switch ($bettype)
{
    case 27 :
        $i = 1;
        while ($i <= 12)
        {
            $html .= "<td>" . $g_chinayear[$i] . "&nbsp;<font color='#FF0000'>" . floatval($rs->f["r" . d2($i)]) . "</font>&nbsp;<input type='button' onclick=\"ratediff({$bettype},{$subid},{$i},-0.1);\" value='-' class=btnmin>&nbsp;<input type='button' onclick=\"ratediff({$bettype},{$subid},{$i},0.1);\" value='+' class=btnplus></td>";
            $html .= "</tr><tr>";
            ++$i;
        }
        break;
    case 36 :
        $i = 0;
        while ($i <= 9)
        {
            $html .= "<td>" . $i . "尾&nbsp;<font color='#FF0000'>" . floatval($rs->f["r" . $i]) . "</font>&nbsp;<input class='btnmin' type='button' onclick=\"ratediff({$bettype},{$subid},{$i},-0.1);\" value='-' />&nbsp;<input type='button' onclick=\"ratediff({$bettype},{$subid},{$i},0.1);\" value='+' class=btnplus></td>";
            if ($i % 3 == 2)
            {
                $html .= "</tr><tr>";
            }
            ++$i;
        }
        break;
}
$html .= "</tr></table>";
$myChsbtn = "<div id=\"divMyChsbtn\">";
$myChsbtnArr = array(5, 4, 3, 2, 1, 0.5, 0.4, 0.3, 0.2, 0.1, 0.05, 0.03, 0.01, 0.005, 0.001);
$btnRate = floatval(getvar("btnRate"));
$btnRate = $btnRate == 0 ? 0.01 : $btnRate;
foreach ($myChsbtnArr as $val)
{
    $tempChr = $val == $btnRate ? "d" : "";
    $myChsbtn .= "<span class=\"btnchoice{$tempChr}\">{$val}</span>";
}
$myChsbtn .= "</div>";
$tpl->load("main", "ratePanel.htm");
$tpl->set(array("tbdList" => $html, "lotto_id" => $lotto_id, "myChsbtn" => $myChsbtn));
$tpl->show("main");
echo "</body></html>";
?>